翻訳と辞書
Words near each other
・ Clostridium straminisolvens
・ Clostridium tertium
・ Clostridium tetani
・ Clostridium thermocellum
・ Clostridium thermosaccharolyticum
・ Clostridium tyrobutyricum
・ Clostridium uliginosum
・ Clostridium vaccine
・ Clostripain
・ Closure
・ Closure & Container Manufacturers Association
・ Closure (atmospheric science)
・ Closure (band)
・ Closure (business)
・ Closure (Chevelle song)
Closure (computer programming)
・ Closure (container)
・ Closure (EP)
・ Closure (Gabrielle song)
・ Closure (Integrity album)
・ Closure (mathematics)
・ Closure (psychology)
・ Closure (Scarlett Belle song)
・ Closure (sociology)
・ Closure (The X-Files)
・ Closure (topology)
・ Closure (video game)
・ Closure (video)
・ Closure (wine bottle)
・ Closure by stealth


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Closure (computer programming) : ウィキペディア英語版
Closure (computer programming)

In programming languages, closures (also lexical closures or function closures) are a technique for implementing lexically scoped name binding in languages with first-class functions. Operationally, a closure is a record storing a function together with an environment:〔Sussman and Steele. "Scheme: An interpreter for extended lambda calculus". "... a data structure containing a lambda expression, and an environment to be used when that lambda expression is applied to arguments." (Wikisource)〕 a mapping associating each free variable of the function (variables that are used locally, but defined in an enclosing scope) with the value or storage location to which the name was bound when the closure was created. A closure—unlike a plain function—allows the function to access those ''captured variables'' through the closure's reference to them, even when the function is invoked outside their scope.
Example. The following program fragment defines a higher-order function startAt with a parameter x and a nested function incrementBy. The nested function incrementBy has access to x, because incrementBy is in the lexical scope of x, even though x is not local to incrementBy. The function startAt returns a closure containing the function incrementBy, which adds the y value to the x value, and a reference to the variable x ''from this invocation'' of startAt, so incrementBy will know where to find it once invoked:
function startAt(x)
function incrementBy(y)
return x + y
return incrementBy

variable closure1 = startAt(1)
variable closure2 = startAt(5)
Note that, as startAt returns a function, the variables closure1 and closure2 are of function type. Invoking closure1(3) will return 4, while invoking closure2(3) will return 8. While closure1 and closure2 refer to the same function incrementBy, the associated environments differ, and invoking the closures will bind the name x to two distinct variables with different values in the two invocations, thus evaluating the function to different results.
== History and etymology ==
The concept of closures was developed in the 1960s for the mechanical evaluation of expressions in the λ-calculus and was first fully implemented in 1970 as a language feature in the PAL programming language to support lexically scoped first-class functions.〔David A. Turner (2012). ("Some History of Functional Programming Languages" ). Trends in Functional Programming '12.〕
Peter J. Landin defined the term ''closure'' in 1964 as having an ''environment part'' and a ''control part'' as used by his SECD machine for evaluating expressions. Joel Moses credits Landin with introducing the term ''closure'' to refer to a lambda expression whose open bindings (free variables) have been closed by (or bound in) the lexical environment, resulting in a ''closed expression'', or closure. This usage was subsequently adopted by Sussman and Steele when they defined Scheme in 1975, a lexically scoped variant of LISP, and became widespread.

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Closure (computer programming)」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.